import { ElMessageBox } from 'element-plus';


/**
 * @description 全局的弹窗对话函数，element messagebox二次封装
 * @export
 * @param {string} message
 * @param {boolean} [html=false]
 * @param {string} [title='提示']
 * @return {*}
 */
export function messageBox(message, html = false, title = '提示') {
  return new Promise(resovle => {
    ElMessageBox.confirm(message, title, {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      type: 'warning',
      dangerouslyUseHTMLString: html
    })
      .then(() => {
        resovle(0);
      })
      .catch(() => {});
  });
}
/**
 * @description 弹窗确认框
 * @export
 * @param {string} message
 * @param {boolean} [html=false]
 * @param {string} [title='请确认']
 * @return {*}
 */
export function messagePrompt(message, html = false, title = '请确认') {
  return new Promise(resovle => {
    ElMessageBox.prompt(message, title, {
      confirmButtonText: '确认',
      cancelButtonText: '取消',
      dangerouslyUseHTMLString: html
    })
      .then(({ value }) => {
        resovle(value);
      })
      .catch(() => {});
  });
}

export default {
  messageBox,
  messagePrompt
}